<!--
 * @Author: your name
 * @Date: 2020-03-09 11:52:59
 * @LastEditTime: 2020-07-02 11:37:39
 * @LastEditors: jlzm
 * @Description: In User Settings Edit
 * @FilePath: \MPShop\pages\common\pages\login\login.vue
--> 
<template>
	<view class="df df-c container">
		<image
			:src="
				(shopInfo.logo && `${baseFileUri}${shopInfo.logo}`) ||
					`${baseCommonFileUri}image/shop_default.png`
			"
			class="logo"
		></image>
		<view class="name">{{ shopInfo.shopName || "" }}</view>
		<view class="df df-c jc-c btn-group">
			<button
				:style="themeStyles.btnFullColor"
				open-type="getUserInfo"
				@getuserinfo="onLogin"
				class="btn btn-full"
				type="primary"
			>
				快捷登录/注册
			</button>
			<button
				:style="themeStyles.btnAuxiliaryColor"
				@click="cancelLogin()"
				class="btn"
			>
				取消
			</button>
		</view>
	</view>
</template>

<script>
const app = getApp();
import { mapState } from "vuex";
import loginMixin from "@/mixins/login";
export default {
	mixins: [loginMixin],
	data() {
		return {
			shopData: {}
		};
	},

	computed: {
		...mapState("shop", ["shopInfo"])
	},

	onLoad() {
		console.log("this.shopInfo", this.shopInfo);
	},

	onShow() {
		
	},

	methods: {
		async onLogin(e) {
			uni.showLoading({ title: "登入中" });
			try {
				await this.login(e);
				await this.$api.showToast("成功登录");
				// 从领券中心(二维码分享进入---未登录)跳转
				if(app.globalData.openCCByShareQrcode){
					app.globalData.openCCByShareQrcode = false;
					// 跳转标识
					app.globalData.openCCByShareQrcodeFromLogin = true;
				}
				//
				uni.navigateBack();
			} catch (error) {
				this.$api.showToast(error.resultInfo || "登录失败");
			}
		},

		cancelLogin() {
			uni.navigateBack();
		}
	}
};
</script>

<style lang="scss" scoped>
@import "@/pages/common/styles/login/login.scss";
</style>